
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><?php echo $title;?></title>
    <!-- 设置缩放 -->
    <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <!-- IOS中禁用将数字识别为电话号码/忽略Android平台中对邮箱地址的识别 -->
    <meta name="format-detection" content="telephone=no" />
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- icon -->
    <link rel="shortcut icon" href="<?php echo ADMIN_ICO_PIC;?>" type="image/x-icon"/>
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SYS_LINK;?>admin/css/content.css?v=<?php echo V_CSSJS;?>" />

    <style>

    </style>
</head>
<?php
$userLevel = getUserLevel();
$navtype = isset($navtype) ? $navtype : 0;
$powerInfo = isset($powerInfo) ? $powerInfo : powerInfoListDeVal();
?>
<body>
    <!--<div class="crumb_box">菜单管理 > 菜单列表</div><div class="crumb_bottom"></div>-->
    <div class="con_box">
        <div class="lab_box2" >
            <?php
            $classAct1 = $navtype == 1 ? 'act' : '';
            $classAct1line = $navtype == 1 ? '<i class="lab_act2"></i>' : '';
            $classAct2 = $navtype == 2 ? 'act' : '';
            $classAct2line = $navtype == 2 ? '<i class="lab_act2"></i>' : '';
            $urlField = SYS_URL_PATH("admin_field_index/sortflag/1/tableid/1");
            $urlNavTop = SYS_URL_PATH("admin_menu_sysnav");
            $urlNavTopAdd = SYS_URL_PATH("admin_menu_add/navtype/1");
            $urlNavleft = SYS_URL_PATH("admin_menu_index");
            $urlNavleftAdd = SYS_URL_PATH("admin_menu_add/navtype/2");
            if($userLevel == 1){
                echo '<a href="javascript:;" data-url="'.$urlField.'" class="lab_base2 btn_field_main" >字段管理</a>'.PHP_EOL;
                echo '<a href="'.$urlNavTop.'" class="lab_base2 '.$classAct1.'" >顶部菜单'.$classAct1line.'</a>'.PHP_EOL;
                echo '<a href="javascript:;" class="lab_base2 menu_add_btn2" data-url="'.$urlNavTopAdd.'">+顶部菜单</a>'.PHP_EOL;
            }
            echo '<a href="'.$urlNavleft.'" class="lab_base2 '.$classAct2.'">左侧菜单'.$classAct2line.'</a>'.PHP_EOL;
            if($userLevel == 1){
                echo '<a href="javascript:;" class="lab_base2 menu_add_btn" data-url="'.$urlNavleftAdd.'">+左侧菜单</a>'.PHP_EOL;
            }
            ?>
        </div>
        <table class="table_th_td table_line" >
            <tr class="weight400">
                <th width="50">排序</th>
                <th width="50">ID</th>
                <th class="left">菜单名称</th>
                <?php if($userLevel == 1){ ?>
                <th width="100">所属分类</th>
                <th width="50">类型</th>
                <th width="60">菜单位</th>
                <?php } ?>
                <th width="50">状态</th>
                <th width="200">操作</th>
            </tr>
            <?php
            foreach($classlist as $v){
                $id = $v['id'];
                $viewseq = $v['viewseq'];
                $menuname = $v['menuname'];
                $mouldname = $v['mouldname'] ? $v['mouldname'] : $v['mould_code'];
                $showtypetxt = $v['showtypetxt'];
                $statustxt = $v['statustxt'];
                $navtype = $v['navtype'];
                $level = $v['level']*2;
                $str = str_pad("", $level, '-',STR_PAD_LEFT );
                $fontb = $v['fid'] == 0 ? 'fontb' : '';
                $statusC = $v['status'] == 2 ? 'statusClose' : ($v['status'] == 3 ? 'statusHide' : '');
                $addFindUrl = SYS_URL_PATH("admin_menu_add/c/$id/fid/$id/navtype/$navtype");
                $updateUrl = SYS_URL_PATH("admin_menu_update/c/$id/id/$id/navtype/$navtype");
                $delUrl = SYS_URL_PATH("admin_menu_del/c/$id/id/$id");
                $homeFlagTxt = $v['homeflagtxt'];
                $addDisplayNone = in_array($id.'_add', $powerInfo['classfun']) || $userLevel == 1 ? '' : 'userLevelNone';
                $updateDisplayNone = in_array($id.'_update', $powerInfo['classfun']) || $userLevel == 1 ? '' : 'userLevelNone';
                $delDisplayNone = in_array($id.'_del', $powerInfo['classfun']) || $userLevel == 1 ? '' : 'userLevelNone';
                $addTd = '';
                if($userLevel == 1){
                    $addTd .= '<td class="center">'.$mouldname.'</td>'.PHP_EOL;
                    $addTd .= '<td class="center">'.$showtypetxt.'</td>'.PHP_EOL;
                    $addTd .= '<td class="center">'.$homeFlagTxt.'</td>'.PHP_EOL;
                }
                echo <<<html
            <tr>
                <td class="center"><input type="text" class="viewseq" data-id="$id" value="$viewseq"></td>
                <td class="center">$id</td>
                <td class="other_btn $fontb" data-url="$updateUrl">$str $menuname</td>
                $addTd
                <td class="center $statusC">$statustxt</td>
                <td class="center">
                    <a href="javascript:;" data-type="$navtype" data-url="$addFindUrl" class="btn_base btn_line_none btn_menu_addfind $addDisplayNone" >添加下级</a>
                    <a href="javascript:;" data-type="$navtype" data-url="$updateUrl" class="btn_base btn_line_none btn_update $updateDisplayNone" >编辑</a>
                    <a href="javascript:;" data-url="$delUrl" class="btn_base btn_line_none btn_menu_del $delDisplayNone" >删除</a>
                </td>
            </tr>
html;

            }
            ?>
            <tr class="operates_box">
                <td class="center" >
                    <?php
                    if(in_array('admin_menu_seq',$powerInfo['classfun']) || $userLevel == 1){
                        echo '<button class="btn_base btn_height20 btn_line_none" id="viewseq_btn" title="提交排序"
                    data-url="'.SYS_URL_PATH("admin_menu_seq").'">↓↑</button>';
                    }
                    ?>

                </td>
                <td colspan="<?php echo $userLevel == 1 ? '7' : '4';?>"></td>
            </tr>
        </table>
    </div>
</body>
<script language="javascript">
    var cssjsv = '<?php echo V_CSSJS;?>';
    var http_url = '<?php echo SYS_HOST;?>';
    var http_link = '<?php echo SYS_LINK;?>';
    var http_fix = '<?php echo SYS_URL_FIX;?>';
</script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/jquery.min.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/skin.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/common.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript">file_load('list');</script>
<script language="javascript">
    // 页面加载后
    window.onload = function () {

    }

    //字段管理
    $('.btn_field_main').click(function(){
        layerIframeOpen($(this).attr('data-url'), '90%', '90%', 1);
    });

    //添加菜单
    $('.menu_add_btn').click(function(){
        layerIframeOpen($(this).attr('data-url'), '820px', '90%', 1);
    });

    //添加子菜单
    $('.menu_add_btn2').click(function(){
        layerIframeOpen($(this).attr('data-url'), '820px', '720px', 1);
    });

    //菜单子级添加
    $('.btn_menu_addfind').click(function(){
        let goutoURL = $(this).attr('data-url');
        let navType = $(this).attr('data-type');
        if(!goutoURL){
            layer.msg('网络异常');
        }else{
            if(navType == 1){
                layerIframe(goutoURL, '820px', '90%', 1);
            }else{
                layerIframe(goutoURL, '820px', '720px', 1);
            }
        }
    })

    //菜单修改
    $('.btn_update').click(function(){
        let goutoURL = $(this).attr('data-url');
        let navType = $(this).attr('data-type');
        if(!goutoURL){
            layer.msg('网络异常');
        }else{
            if(navType == 1){
                layerIframe(goutoURL, '820px', '90%', 1);
            }else{
                layerIframe(goutoURL, '820px', '720px', 1);
            }
        }
    })

    var flagSub = true;
    //菜单删除
    $('.btn_menu_del').click(function(){
        let goutoURL = $(this).attr('data-url');
        if(!goutoURL){
            layer.msg('网络异常');return false;
        }
        layer.confirm('确定删除？', {
            btn: ['确定','取消']
        }, function(){
            if(!flagSub){
                layer.msg('删除中……(禁止重复提交)');return false;
            }
            flagSub = false;
            $.post(goutoURL, {subFlag:'Y'}, function(data){
                if(data=='Y'){
                    layer.msg('删除成功');
                    setTimeout(function(){
                        window.location.reload();
                    },2500);
                }else{
                    layer.msg('操作失败_'+data);
                }
            },'json');
        }, function(){ });
    })

</script>
</html>